/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package lego.util;

import java.util.Map;

import lego.*;

import org.eclipse.emf.common.util.BasicDiagnostic;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.DiagnosticChain;

import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.ecore.EPackage;

import org.eclipse.emf.ecore.plugin.EcorePlugin;

import org.eclipse.emf.ecore.util.EObjectValidator;

/**
 * <!-- begin-user-doc -->
 * The <b>Validator</b> for the model.
 * <!-- end-user-doc -->
 * @see lego.LegoPackage
 * @generated
 */
public class LegoValidator extends EObjectValidator {
	/**
	 * The cached model package
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public static final LegoValidator INSTANCE = new LegoValidator();

	/**
	 * A constant for the {@link org.eclipse.emf.common.util.Diagnostic#getSource() source} of diagnostic {@link org.eclipse.emf.common.util.Diagnostic#getCode() codes} from this package.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see org.eclipse.emf.common.util.Diagnostic#getSource()
	 * @see org.eclipse.emf.common.util.Diagnostic#getCode()
	 * @generated
	 */
	public static final String DIAGNOSTIC_SOURCE = "lego";

	/**
	 * A constant with a fixed name that can be used as the base value for additional hand written constants.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	private static final int GENERATED_DIAGNOSTIC_CODE_COUNT = 0;

	/**
	 * A constant with a fixed name that can be used as the base value for additional hand written constants in a derived class.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected static final int DIAGNOSTIC_CODE_COUNT = GENERATED_DIAGNOSTIC_CODE_COUNT;

	/**
	 * Creates an instance of the switch.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public LegoValidator() {
		super();
	}

	/**
	 * Returns the package of this validator switch.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EPackage getEPackage() {
	  return LegoPackage.eINSTANCE;
	}

	/**
	 * Calls <code>validateXXX</code> for the corresponding classifier of the model.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected boolean validate(int classifierID, Object value, DiagnosticChain diagnostics, Map<Object, Object> context) {
		switch (classifierID) {
			case LegoPackage.ROOT:
				return validateRoot((Root)value, diagnostics, context);
			case LegoPackage.COMPONENT:
				return validateComponent((Component)value, diagnostics, context);
			case LegoPackage.ROBOT:
				return validateRobot((Robot)value, diagnostics, context);
			case LegoPackage.ACTIONER:
				return validateActioner((Actioner)value, diagnostics, context);
			case LegoPackage.MOTOR_ACTIONER:
				return validateMotorActioner((MotorActioner)value, diagnostics, context);
			case LegoPackage.SENSOR:
				return validateSensor((Sensor)value, diagnostics, context);
			case LegoPackage.TOUCH_SENSOR:
				return validateTouchSensor((TouchSensor)value, diagnostics, context);
			case LegoPackage.LIGHT_SENSOR:
				return validateLightSensor((LightSensor)value, diagnostics, context);
			case LegoPackage.MICRO_SENSOR:
				return validateMicroSensor((MicroSensor)value, diagnostics, context);
			case LegoPackage.ULTRA_SOUND_SENSOR:
				return validateUltraSoundSensor((UltraSoundSensor)value, diagnostics, context);
			case LegoPackage.SENSOR_PORT:
				return validateSensorPort((SensorPort)value, diagnostics, context);
			case LegoPackage.ACTIONER_PORT:
				return validateActionerPort((ActionerPort)value, diagnostics, context);
			case LegoPackage.PICO_NET:
				return validatePicoNet((PicoNet)value, diagnostics, context);
			default:
				return true;
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateRoot(Root root, DiagnosticChain diagnostics, Map<Object, Object> context) {
		if (!validate_NoCircularContainment(root, diagnostics, context)) return false;
		boolean result = validate_EveryMultiplicityConforms(root, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryDataValueConforms(root, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryReferenceIsContained(root, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryBidirectionalReferenceIsPaired(root, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryProxyResolves(root, diagnostics, context);
		if (result || diagnostics != null) result &= validate_UniqueID(root, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryKeyUnique(root, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryMapEntryUnique(root, diagnostics, context);
		if (result || diagnostics != null) result &= validateRoot_sensorPortUnicity(root, diagnostics, context);
		if (result || diagnostics != null) result &= validateRoot_actionerPortUnicity(root, diagnostics, context);
		if (result || diagnostics != null) result &= validateRoot_masterUnicity(root, diagnostics, context);
		return result;
	}

	/**
	 * The cached validation expression for the masterUnicity constraint of '<em>Root</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected static final String ROOT__MASTER_UNICITY__EEXPRESSION = "PicoNet.allInstances()->forAll(p1 : PicoNet | p1.slaves->forAll(s : Robot | s <> p1.master))";

	/**
	 * Validates the masterUnicity constraint of '<em>Root</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateRoot_masterUnicity(Root root, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return
			validate
				(LegoPackage.Literals.ROOT,
				 root,
				 diagnostics,
				 context,
				 "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
				 "masterUnicity",
				 ROOT__MASTER_UNICITY__EEXPRESSION,
				 Diagnostic.ERROR,
				 DIAGNOSTIC_SOURCE,
				 0);
	}

	/**
	 * The cached validation expression for the actionerPortUnicity constraint of '<em>Root</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected static final String ROOT__ACTIONER_PORT_UNICITY__EEXPRESSION = "ActionerPort.allInstances()->forAll(a1 : ActionerPort, a2 : ActionerPort | a1.actioner <> a2.actioner or a2.actioner = null and a1.actioner = null)";

	/**
	 * Validates the actionerPortUnicity constraint of '<em>Root</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateRoot_actionerPortUnicity(Root root, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return
			validate
				(LegoPackage.Literals.ROOT,
				 root,
				 diagnostics,
				 context,
				 "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
				 "actionerPortUnicity",
				 ROOT__ACTIONER_PORT_UNICITY__EEXPRESSION,
				 Diagnostic.ERROR,
				 DIAGNOSTIC_SOURCE,
				 0);
	}

	/**
	 * The cached validation expression for the sensorPortUnicity constraint of '<em>Root</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected static final String ROOT__SENSOR_PORT_UNICITY__EEXPRESSION = "SensorPort.allInstances()->forAll(s1 : SensorPort, s2 : SensorPort | s1.sensor = s2.sensor implies s1.sensor = null and s2.sensor = null)";

	/**
	 * Validates the sensorPortUnicity constraint of '<em>Root</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateRoot_sensorPortUnicity(Root root, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return
			validate
				(LegoPackage.Literals.ROOT,
				 root,
				 diagnostics,
				 context,
				 "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
				 "sensorPortUnicity",
				 ROOT__SENSOR_PORT_UNICITY__EEXPRESSION,
				 Diagnostic.ERROR,
				 DIAGNOSTIC_SOURCE,
				 0);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateComponent(Component component, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(component, diagnostics, context);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateRobot(Robot robot, DiagnosticChain diagnostics, Map<Object, Object> context) {
		if (!validate_NoCircularContainment(robot, diagnostics, context)) return false;
		boolean result = validate_EveryMultiplicityConforms(robot, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryDataValueConforms(robot, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryReferenceIsContained(robot, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryBidirectionalReferenceIsPaired(robot, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryProxyResolves(robot, diagnostics, context);
		if (result || diagnostics != null) result &= validate_UniqueID(robot, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryKeyUnique(robot, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryMapEntryUnique(robot, diagnostics, context);
		if (result || diagnostics != null) result &= validateRobot_bluetoothVisibility(robot, diagnostics, context);
		if (result || diagnostics != null) result &= validateRobot_connectionStatus(robot, diagnostics, context);
		if (result || diagnostics != null) result &= validateRobot_connectionStatusInterval(robot, diagnostics, context);
		return result;
	}

	/**
	 * The cached validation expression for the bluetoothVisibility constraint of '<em>Robot</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected static final String ROBOT__BLUETOOTH_VISIBILITY__EEXPRESSION = "self.bluetoothOn = false implies self.bluetoothVisible = false";

	/**
	 * Validates the bluetoothVisibility constraint of '<em>Robot</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateRobot_bluetoothVisibility(Robot robot, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return
			validate
				(LegoPackage.Literals.ROBOT,
				 robot,
				 diagnostics,
				 context,
				 "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
				 "bluetoothVisibility",
				 ROBOT__BLUETOOTH_VISIBILITY__EEXPRESSION,
				 Diagnostic.ERROR,
				 DIAGNOSTIC_SOURCE,
				 0);
	}

	/**
	 * The cached validation expression for the connectionStatus constraint of '<em>Robot</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected static final String ROBOT__CONNECTION_STATUS__EEXPRESSION = "self.bluetoothOn = false implies self.connectionStatus = - 1";

	/**
	 * Validates the connectionStatus constraint of '<em>Robot</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateRobot_connectionStatus(Robot robot, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return
			validate
				(LegoPackage.Literals.ROBOT,
				 robot,
				 diagnostics,
				 context,
				 "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
				 "connectionStatus",
				 ROBOT__CONNECTION_STATUS__EEXPRESSION,
				 Diagnostic.ERROR,
				 DIAGNOSTIC_SOURCE,
				 0);
	}

	/**
	 * The cached validation expression for the connectionStatusInterval constraint of '<em>Robot</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected static final String ROBOT__CONNECTION_STATUS_INTERVAL__EEXPRESSION = "self.connectionStatus >= - 1 and self.connectionStatus <= 3";

	/**
	 * Validates the connectionStatusInterval constraint of '<em>Robot</em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateRobot_connectionStatusInterval(Robot robot, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return
			validate
				(LegoPackage.Literals.ROBOT,
				 robot,
				 diagnostics,
				 context,
				 "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
				 "connectionStatusInterval",
				 ROBOT__CONNECTION_STATUS_INTERVAL__EEXPRESSION,
				 Diagnostic.ERROR,
				 DIAGNOSTIC_SOURCE,
				 0);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateActioner(Actioner actioner, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(actioner, diagnostics, context);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateMotorActioner(MotorActioner motorActioner, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(motorActioner, diagnostics, context);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateSensor(Sensor sensor, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(sensor, diagnostics, context);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateTouchSensor(TouchSensor touchSensor, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(touchSensor, diagnostics, context);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateLightSensor(LightSensor lightSensor, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(lightSensor, diagnostics, context);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateMicroSensor(MicroSensor microSensor, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(microSensor, diagnostics, context);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateUltraSoundSensor(UltraSoundSensor ultraSoundSensor, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(ultraSoundSensor, diagnostics, context);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateSensorPort(SensorPort sensorPort, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(sensorPort, diagnostics, context);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validateActionerPort(ActionerPort actionerPort, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(actionerPort, diagnostics, context);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean validatePicoNet(PicoNet picoNet, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(picoNet, diagnostics, context);
	}

	/**
	 * Returns the resource locator that will be used to fetch messages for this validator's diagnostics.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public ResourceLocator getResourceLocator() {
		// TODO
		// Specialize this to return a resource locator for messages specific to this validator.
		// Ensure that you remove @generated or mark it @generated NOT
		return super.getResourceLocator();
	}

} //LegoValidator
